package com.base.cn.platform.os.controller.count;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.service.course.count.CourseCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 观看数据统计Controller
 *
 * @author s.li
 * @create 2018-08-24-16:55
 */
@Controller
@RequestMapping("/admin/count")
public class WatchCountStatisticsController extends AdminBaseController {

    @Autowired
    private CourseCountService courseCountService;

    @RequestMapping("/watchCount")
    public String watchCount(){
        return resultPage("/count/watch-statistics");
    }

    /**
     * 获取观看的基本数据统计数据
     * @return Map<String,Object>
     */
    @RequestMapping("/watchBaseCount")
    @ResponseBody
    public Map<String,Object> watchBaseCount(){
        Map<String,Object> v96kData = courseCountService.get96KCountData();
        Map<String,Object> dataMap = new HashMap<>();
        dataMap.put("v96kData",v96kData);
        return ResultUtil.SUCCESS(dataMap);
    }

    /**
     * 获取96K当月观看流量曲线
     * @return Map<String,Object>
     */
    @RequestMapping("/query96KMonthDataCount")
    @ResponseBody
    public Map<String,Object> query96KMonthDataCount(@RequestBody Map<String,String> maps){
        List<Map<String,Object>> monthDataCountList = courseCountService.query96KMonthDataCount(maps);
        return ResultUtil.SUCCESS(monthDataCountList);
    }

    /**
     * 获取视频观看量 TOP10的专业/科目
     * @return Map<String,Object>
     */
    @RequestMapping("/queryTopSubjectPlayCount")
    @ResponseBody
    public Map<String,Object> queryTopSubjectPlayCount(){
        List<Map<String,Object>> topSubjectPlayCountList = courseCountService.queryTopSubjectPlayCount();
        return ResultUtil.SUCCESS(topSubjectPlayCountList);
    }

    /**
     * 获取访问量最的前10场直播
     * @return Map<String,Object>
     */
    @RequestMapping("/queryToLiveCount")
    @ResponseBody
    public Map<String,Object> queryToLiveCount(){
        List<Map<String,Object>> toLiveCountList = courseCountService.queryToLiveCount();
        return ResultUtil.SUCCESS(toLiveCountList);
    }
}
